package com.edu.controller;

import org.springframework.util.FileCopyUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileOutputStream;

public class ImageController {


//保存图片
    public static String imageSave( MultipartFile file, String memberNo) throws Exception {
    String localPath = "E:\\Java EE tomcat\\apache-tomcat-9.0.31\\webapps\\img\\people";
    String exName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
    String fileName = memberNo+exName;
    FileCopyUtils.copy(file.getInputStream(),new FileOutputStream(new File(localPath+fileName)));

          return fileName;
    }

}
